From 664c0b32f3eee9ee0e10c9544aed2f2d237fd763 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Sat, 9 Jul 2005 15:58:08 +0000 Subject: [PATCH] - ocaml-md5sums will now delete the registry file if, after an update, it no longer contains any entry (actually if it is empty) - on removal update registry in prerm script instead of postrm one so that registry dir could be deleted by dpkg if empty - bugfix in Makefile: scripts are installed again when creating debhelper package --- Makefile | 1 + dh_ocaml | 8 ++++---- ocaml-md5sums.ml.in | 21 +++++++++++++-------- postrm-ocaml => prerm-ocaml | 0 4 files changed, 18 insertions(+), 12 deletions(-) rename postrm-ocaml => prerm-ocaml (100%) diff --git a/Makefile b/Makefile index 203e80bd..d44e28b8 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ FED_SUMS = ocaml-nox.md5sums ocaml.md5sums ocaml-compiler-libs.md5sums OCAMLC = ocamlc OCAMLOPT = ocamlopt OCAML_LIBS = unix str +SCRIPTS = postinst-ocaml prerm-ocaml all: ocaml-md5sums opt: ocaml-md5sums.opt diff --git a/dh_ocaml b/dh_ocaml index 7eaa5e86..9666137c 100755 --- a/dh_ocaml +++ b/dh_ocaml @@ -72,9 +72,9 @@ imported units will instead be used as keys in the OCaml md5sums registry for retrieving dependency information for the package. Those information will then be used to fill the "${ocaml:Depends}" substvar. -dh_ocaml takes also care of creating postinst and postrm autoscripts which -update the global system registry (/var/lib/ocaml/md5sums/MD5SUMS) with the -registry entry shipped by your package. +dh_ocaml takes also care of creating postinst and prerm autoscripts which update +the global system registry (/var/lib/ocaml/md5sums/MD5SUMS) with the registry +entry shipped by your package. On non-library packages, dh_ocaml tries to guess the OCaml objects corresponding to shipped bytecode binaries and extract from them information about imported @@ -250,7 +250,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) { . " | sort -k 2" # optional pass, just for "pretty" printing . " > $tmp$md5dir/$package$md5ext"); autoscript $package, "postinst", "postinst-ocaml"; - autoscript $package, "postrm", "postrm-ocaml"; + autoscript $package, "prerm", "prerm-ocaml"; complex_doit "$omd5 --load-info $oinfo dep < $olist > $odeps"; #compute deps fill_ocaml_depends $package, $tmp, $odeps, 1, $runtime; } elsif (is_binary $package, $dh{L_PARAMS}) { # ocaml binary package diff --git a/ocaml-md5sums.ml.in b/ocaml-md5sums.ml.in index 3aafb209..dc5dceec 100644 --- a/ocaml-md5sums.ml.in +++ b/ocaml-md5sums.ml.in @@ -4,7 +4,7 @@ * Copyright (C) 2005, Stefano Zacchiroli * * Created: Wed, 06 Apr 2005 16:55:39 +0200 zack - * Last-Modified: Mon, 11 Apr 2005 10:39:58 +0200 zack + * Last-Modified: Sat, 09 Jul 2005 17:40:44 +0200 zack * * This is free software, you can redistribute it and/or modify it under the * terms of the GNU General Public License version 2 as published by the Free @@ -98,6 +98,8 @@ let read_stdin () = iter_in (fun s -> lines := s :: !lines) stdin; List.rev !lines +let is_empty fname = (Unix.stat fname).Unix.st_size = 0 + (** {2 Auxiliary functions} *) (** loads info previously stored in a file using --dump-info and stores them in @@ -200,17 +202,19 @@ let iter_registry f fname = fname !lineno))) fname -(** @param fname file name of the registry file +(** @param fname file name of the registry file, if fname does not exists an + * empty registry will be returned * @return an hashtbl mapping pairs to pairs . E.g. ("Foo_bar", "74be7fa4320ebd9415f1c7cfc04c2d7b") -> * ("libfoo-ocaml-dev", ">= 1.2.3-4") *) let parse_registry fname = let registry = Hashtbl.create 1024 in - iter_registry - (fun ~md5sum ~unit_name ~dev_dep ~runtime_dep ~dep_version -> - Hashtbl.replace registry (unit_name, md5sum) - (dev_dep, runtime_dep, dep_version)) - fname; + if Sys.file_exists fname then + iter_registry + (fun ~md5sum ~unit_name ~dev_dep ~runtime_dep ~dep_version -> + Hashtbl.replace registry (unit_name, md5sum) + (dev_dep, runtime_dep, dep_version)) + fname; registry (** {2 Main functions, one for each command line action} *) @@ -266,7 +270,8 @@ let update () = done with End_of_file -> Unix.closedir dir; - close_out registry + close_out registry; + if is_empty registry_file then Sys.remove registry_file (** {2 Main} *) diff --git a/postrm-ocaml b/prerm-ocaml similarity index 100% rename from postrm-ocaml rename to prerm-ocaml -- 2.30.2